﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;
using System.Data;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using GestionaleLib.DataSet;


namespace GestionaleLib.Controller
{
    public class ctrlStampe
    {
        string myConnectionString = @"Data Source=|DataDirectory|\Data.sdf";

            dsVendita ds = new dsVendita(); // .xsd file name
            DataTable dt = new DataTable();


        public bool Connessione()
        {
            //dt.TableName = "Riepilogo Vendita"; 
            //dt = getAllOrders(); //This function is located below this function
            //ds.Tables[0].Merge(dt);

            string serverName = @"";
            try
            {
                SqlCeConnection myConnection = new SqlCeConnection();
                myConnection.ConnectionString = myConnectionString;
                myConnection.Open();

                return true;
            }
            catch 
            {

                return false;
            }
        }

        //public DataTable getAllOrders()
        //{
        //    //Connection string replace 'databaseservername' with your db server name
        //    string sqlCon = "User ID=sa;PWD=sa; server=databaseservername;INITIAL CATALOG=SampleDB;" +
        //                        "PERSISTSECURITY INFO=FALSE;Connect Timeout=0";
        //    SqlConnection Con = new SqlConnection(myConnectionString);
        //    SqlCommand cmd = new SqlCommand();
        //    DataSet ds = null;
        //    SqlDataAdapter adapter;
        //    try
        //    {
        //        Con.Open();
        //        cmd.CommandText = "getAllOrders";
        //        cmd.CommandType = CommandType.StoredProcedure;
        //        cmd.Connection = Con;
        //        ds = new DataSet();
        //        adapter = new SqlDataAdapter(cmd);
        //        adapter.Fill(ds, "Users");
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }
        //    finally
        //    {
        //        cmd.Dispose();
        //        if (Con.State != ConnectionState.Closed)
        //            Con.Close();
        //    }
        //    return ds.Tables[0];
        //}
    }
}
